<?php
if (!defined('WEB_ROOT')) {
	exit;
}
	
// for paging
// how many rows to show per page
$rowsPerPage = 7;

$sql = "SELECT nn.id, mann, tennn, dv_id, tendv
        FROM nhomnganh nn left join donvi dv on nn.dv_id = dv.id
		WHERE nn.hieu_luc > 0
		ORDER BY nn.id desc";
$result     = dbQuery(getPagingQuery($sql, $rowsPerPage));
$pagingLink = getPagingLink($sql, $rowsPerPage);
?>
<!-- Begin one column window -->
<div class="onecolumn">
				<div class="header">
					<span>Nhóm đề tài</span>
					<div class="switch" style="width:140px">
						<table width="140px" cellpadding="0" cellspacing="0">
						<tbody>
							<tr>
								<td>
									<input name="btnAddGroup" class="middle_switch" type="button" id="btnAddGroup" value="Thêm nhóm ngành"  style="width:140px" onClick="addTopicGroup()">
								</td>
							</tr>
						</tbody>
						</table>
					</div>
				</div>
				<br class="clear"/>
				<div class="content">
					<form action="processTopicGroup.php?action=add" method="post"  name="frmListTopicGroup" id="frmListTopicGroup">
					 <table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="data">
					  <tr align="center" id="listTableHeader"> 
					   <th width="85" align="center">Mã nhóm ngành</th>
					   <th align="center">Tên nhóm ngành</th>
					   <th width="200" align="center">Ðơn vị</th>
					   <th width="55" align="center">Sửa</th>
					   <th width="55" align="center">Xóa</th>
					  </tr>
					  <?php
					  
					if (dbNumRows($result) > 0) {
						$i = 0;
						while($row = dbFetchAssoc($result)) {
							extract($row);
							
							if ($i%2) {
								$class = 'row1';
							} else {
								$class = 'row2';
							}
							
							$i += 1;
							
					?>
					  <tr class="<?php echo $class; ?>"> 
							<td width="85" align="center"><?php echo $mann; ?></td>
							<td><?php echo $tennn; ?></td>
							<td width = "200"><?php echo $tendv; ?></td>
						
							<td width="30" ><a href="javascript:modifyTopicGroup(<?php echo $id; ?>, <?php echo (int)$dv_id; ?>);">Sửa</a></td>
							<td width="30" ><a href="javascript:deleteTopicGroup(<?php echo $id; ?>);">Xóa</a></td>
					  </tr>
					  <?php
						} // end while


					?>
					  <tr> 
					   <td colspan="5" align="center">
					   <?php 
					   echo $pagingLink;
					   ?></td>
					  </tr>
					<?php	
					} 
					else {
					?>
					  <tr> 
					   <td colspan="5" align="center">Không có nhóm ngành nào</td>
					  </tr>
					  <?php
					}
					?>
					 </table>
					 <p>&nbsp;</p>
					</form>
</div>
</div>